package com.ljl.ningwei.common.result;

import lombok.Data;

/**
 * @author 吕佳乐
 * @version 1.0
 * @date 2025-03-17 20:39
 */
@Data
public class Result<T> {

    /**
     * 响应数据
     */
    private T data;
    /**
     * 正确返回码
     */
    public static final String SUCCESS_CODE = "0";

    /**
     * 返回码
     */
    private String code;

    /**
     * 返回消息
     */
    private String message;
    /**
     * 返回成功状态
     */
    private Boolean success = true;

    public static <T> Result<T> success() {
        return success(null);
    }

    public static <T> Result<T> success(T data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setData(data);
        return result;
    }
    public static <T> Result<T> error() {
        return error(null);
    }
    public static <T> Result<T> error(T data) {
        Result result = new Result();
        result.setSuccess(false);
        result.setData(data);
        return result;
    }
}
